package models

import (
	"gorm.io/gorm"
	"time"
)

type MyAnimal struct {
	gorm.Model
	Image     string //头像
	NickName  string //昵称
	Age       int64  //年龄
	Sex       string //性别
	TypesId   int64  //类型
	TheSexy   int64  //绝育情况  1-是 2-否
	TheHealth int64  ///疫苗情况 1-是 2-否
	TheQu     int64  //驱虫情况  1-是 2-否
}

func (anm *MyAnimal) Create(db *gorm.DB) error {
	return db.Create(&anm).Error
}

func (anm *MyAnimal) GeyAnimalInfoByNickName(db *gorm.DB, nickName string) error {
	return db.Where("nick_name =?", nickName).Limit(1).Find(&anm).Error
}

type MyAds struct {
	gorm.Model
	UserId   int64  //用户ID
	NickName string //昵称
	Mobile   string //电话号码
	Ads      string //地址
}

func (ads *MyAds) ListMyAds(db *gorm.DB, userId int64) (list []MyAds, err error) {
	err = db.Model(&ads).
		Where("user_id=?", userId).
		Find(&list).Error

	return list, err
}

type TypesList struct {
	gorm.Model
	Title   string  //标题
	Price   float32 //价格
	Comment string  //服务内容
	Stock   int64   //库存
}

func (t *TypesList) ListTypes(db *gorm.DB) (list []TypesList, err error) {
	err = db.Model(&t).
		Find(&list).Error

	return list, err
}

func (t *TypesList) TypesInfo(db *gorm.DB, id int64) error {
	return db.Where("id=?", id).Limit(1).Find(&t).Error
}

type Orders struct {
	gorm.Model
	UserId    int64 //用户ID
	OrderSn   string
	GoodsID   int64     //服务内容 1-皮毛护理 2-口腔护理 3-头部护理
	TeacherId int64     //美容师ID
	DataTime  time.Time //服务时间
	Comment   string    //备注信息
	Num       int64     //数量
	Total     float32   //总价
}

func (o *Orders) CreateOrder(db *gorm.DB) error {
	return db.Create(&o).Error
}

func (o *Orders) GetOrderByOrderSn(db *gorm.DB, orderSn string) error {
	return db.Where("order_sn =?", orderSn).Limit(1).Find(&o).Error
}

type ChangeTypes struct {
	PopeId  int64
	AdsId   int64
	Shop    string
	TypesId int64
}

func (c *ChangeTypes) CreateChangeTypes(db *gorm.DB) error {
	return db.Create(&c).Error
}
